<?php

namespace common\model;

use think\model\RelationModel;

class ReviewRequestModel extends RelationModel
{

    //自动验证
    protected $_validate = [
        ['name', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['name', '1,255', '', self::EXISTS_VALIDATE, 'length'],
        ['tenant_id', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['review_workflow_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],
        ['link_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],
        ['link_id', '', '', self::MUST_VALIDATE, 'integer', self::MODEL_INSERT],
        ['module_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],
        ['module_id', '', '', self::EXISTS_VALIDATE, 'integer'],
    ];

    //自动完成
    protected $_auto = [
        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['tenant_id', 'auto_fill_tenant_id_with_data', self::MODEL_INSERT, 'function_with_data'],
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['param', 'json_encode', self::EXISTS_VALIDATE, 'function'],
        ['is_pass', 'fillDefaultNo', self::EXISTS_VALIDATE, 'callback', self::MODEL_INSERT],

    ];

    /**
     * 填充no
     * @param $args
     * @return string
     */
    public function fillDefaultNo($args)
    {
        if (empty($args)) {
            return "no";
        }
        return $args;
    }
}
